import 'dart:convert';


import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_easyrefresh/material_footer.dart';
import 'package:flutter_module/view_model/json_quey.dart';
import 'package:flutter_module/view_model/query_model.dart';
import 'package:flutter_module/widget/provider_widget.dart';
import 'package:flutter_module/widget/tap_appbar.dart';
import 'package:flutter_screenutil/screenutil.dart';

import '../amap.dart';
import 'Indicator.dart';

class JsonEngineeringQuery extends StatefulWidget {
  @override
  _JsonEngineeringQuery createState() => _JsonEngineeringQuery();
}

class _JsonEngineeringQuery extends State<JsonEngineeringQuery> {
//  final isTouched = i+1 == touchedIndex;
//  final double fontSize = isTouched ? 25 : 16;
//  final double radius = isTouched ? 70 : 60;
  Map<String, String> wgfgsMap = {
    "1": "网管一分",
    "2": "网管二分",
    "3": "网管三分",
    "4": "网管四分",
    "5": "中水分公司",
  };

  Map<String, String> xmbMap = {
    "1": "一项",
    "2": "二项",
    "3": "三项",
    "4": "四项",
  };

  Map<String, Color> colorMap = {
    "1": Colors.brown,
    "2": Colors.limeAccent,
    "3": Colors.purpleAccent,
    "4": Colors.pinkAccent,
    "5": Colors.deepOrangeAccent,
    "6": Colors.blueGrey,
    "7": Colors.blue,
    "8": Colors.deepPurple,
    "9": Colors.black87,
    "10": Colors.teal,
    "11": Colors.amber,
    "12": Colors.purple,
  };

  Map<String, String> sgyyList = {
    "2": "线管老化、造成路面或步道未塌陷",
    "4": "盖板老化、造成路面或步道塌陷",
    "5": "盖板老化、造成路面或步道未塌陷",
    "3": "检查井井墙倒塌",
    "7": "雨水篦子倒塌",
    "6": "外单位施工破坏",
    "1": "管线老化、造成路面或步道塌陷",
  };

  Map<String, String> sgfeList = {
    "1": "明开槽换管",
    "12": "非开挖修复（插管）",
    "10": "非开挖修复（喷涂）",
    "11": "非开挖修复（喷涂）",
    "13": "非开挖修复（紫外固化）",
    "14": "非开挖修复（螺旋缠绕）",
    "5": "塌点位置回填，非开挖修复	",
    "3": "锚喷竖井顶管",
    "4": "锚喷竖井插管",
    "6": "拉管",
    "7": "砌筑检查井",
    "8": "砌筑雨水口",
    "9": "更换盖板",
    "2": "化学注浆"
  };

  Map<String, String> technologyMap = {
    "1": "东西城",
    "2": "朝阳",
    "3": "海淀",
    "4": "丰台、石景山",
  };

  List list;
  List technologylist;
  List analysislist;
  List handletimelist;
  var wgfgsValue;

  var value;
  int touchedIndex;
  var xmbValue;
  var gcztValue;
  var xzValue;
  var mmValue;
  var sgyyValue;
  var sgfeValue;
  var sDate = DateTime.now().toString().substring(0, 10);
  var eDat = DateTime.now().toString().substring(0, 8)+"01";
  String datas;
  String pName = "";
  QueryModel queryModel = new QueryModel();
  Map<String, String> queryMap;

  @override
  void initState() {
    // TODO: implement initState
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: TapAppBar(TapViewBar(Text("工程分析"), icon: Icon(Icons.arrow_back)),
          Size.fromHeight(ScreenUtil().setHeight(80))),
      body: ProviderWidget<JsonQueryModel>(
        model: JsonQueryModel(),
        onModelInit: (model) {
          model.getHttpData().then((value) {
            this.datas = model.datas;
          });
        },
        builder: (context, model, child) {
          return EasyRefresh(
              controller: model.controller,
              footer: MaterialFooter(),
              enableControlFinishLoad: true,
              onLoad: model.onLoad,
              bottomBouncing: true,
              child: SingleChildScrollView(
                child: Column(
                  children: <Widget>[
                    getItem("网管分公司", wgfgsMap),
                    SizedBox(
                      height: 1,
                      width: ScreenUtil().setWidth(700),
                      child: Container(
                        color: Colors.black12,
                      ),
                    ),
                    Container(
                      color: Colors.white,
                      child: getDate("开始时间"),
                    ),
                    SizedBox(
                      height: 1,
                      width: ScreenUtil().setWidth(700),
                      child: Container(
                        color: Colors.black12,
                      ),
                    ),
                    Container(
                      color: Colors.white,
                      child: getDate2("结束时间"),
                    ),
                    SizedBox(
                      height: 1,
                      width: ScreenUtil().setWidth(700),
                      child: Container(
                        color: Colors.black12,
                      ),
                    ),
                    getItem2("项目部 ", xmbMap),
                    SizedBox(
                      height: 1,
                      width: ScreenUtil().setWidth(700),
                      child: Container(
                        color: Colors.black12,
                      ),
                    ),
                    getQuery(model),
//                    getWrap(),
                    pintu(),
                    pintu1(),
                    pintu2(),
                    pintu3(),
                  ],
                ),
              ));
        },
      ),
    );
  }

  Widget getListItemData(String name, String data) {
    return Row(
      children: <Widget>[
        Expanded(
          child: Text(
            name,
            style: TextStyle(fontWeight: FontWeight.bold),
          ),
          flex: 2,
        ),
        SizedBox(
          width: 5,
        ),
        Expanded(
          child: Text(
            data,
            style: TextStyle(color: Colors.black54),
          ),
          flex: 5,
        )
      ],
    );
  }

  Widget getDate(String sDate) {
//    DatePicker da = new DatePicker()
    return Container(
      height: ScreenUtil().setHeight(80),
      child: FlatButton(
          onPressed: () {
            DatePicker.showDatePicker(context,
                showTitleActions: true,
                minTime: DateTime(2010, 3, 5),
                maxTime: DateTime(2030, 6, 7),
                onChanged: (date) {},
                onConfirm: (date) {
                  setState(() {
                    this.sDate = date.toString().substring(0, 10);
                  });
                }, currentTime: DateTime.now(), locale: LocaleType.zh);
          },
          child: Container(
            alignment: Alignment.center,

            margin: EdgeInsets.only(left: 15, right: 30),
            child: Row(
              children: <Widget>[
                Expanded(
                  child: Text(
                    sDate,
                    textAlign: TextAlign.right,
                  ),
                  flex: 2,
                ),
                SizedBox(
                  width: 5,
                ),
                Expanded(
                  child: Text(
                    this.sDate,
                    style: new TextStyle(
                        fontSize: 12, color: const Color(0xff888888)),
                  ),
                  flex: 6,
                )
              ],
            ),
          )),
    );
  }

  Widget getDate2(String eDate) {
    return Container(
      height: ScreenUtil().setHeight(80),
      child: FlatButton(
          onPressed: () {
            DatePicker.showDatePicker(context,
                showTitleActions: true,
                minTime: DateTime(2010, 3, 5),
                maxTime: DateTime(2030, 6, 7),
                onChanged: (date) {}, onConfirm: (date) {
                  setState(() {
                    this.eDat = date.toString().substring(0, 10);
                  });
                }, currentTime: DateTime.now(), locale: LocaleType.zh);
          },
          child: Container(
            alignment: Alignment.center,

            margin: EdgeInsets.only(left: 15, right: 30),
            child: Row(
              children: <Widget>[
                Expanded(
                  child: Text(
                    eDate,
                    textAlign: TextAlign.right,
                  ),
                  flex: 2,
                ),
                SizedBox(
                  width: 5,
                ),
                Expanded(
                  child: Text(
                    this.eDat,
                    style: new TextStyle(
                        fontSize: 12, color: const Color(0xff888888)),
                  ),
                  flex: 6,
                )
              ],
            ),
          )),
    );
  }

  Widget getItem(String title, Map<String, String> list) {
    return Container(
      color: Colors.white,
      alignment: Alignment.center,
      height: ScreenUtil().setHeight(80),
      padding: EdgeInsets.only(left: 30, right: 30),
      child: Row(
        children: <Widget>[
          Expanded(
            child: Text(
              title,
              textAlign: TextAlign.right,
            ),
            flex: 2,
          ),
          SizedBox(
            width: 5,
          ),
          Expanded(
            child: getDownButton(list),
            flex: 6,
          )
        ],
      ),
    );
  }

  Widget getDownButton(Map<String, String> list) {
    var list1 = List<DropdownMenuItem>();
    list.forEach((String key, String value) {
      list1.add(DropdownMenuItem(
          child: Text(value,
              style:
                  new TextStyle(fontSize: 12, color: const Color(0xff888888))),
          value: key));
    });
    return DropdownButtonHideUnderline(
        child: DropdownButton(
            items: list1,
            value: wgfgsValue,
            onChanged: (value) {
              setState(() {
                this.wgfgsValue = value;
              });
            }));
  }

  Widget getItem2(String title, Map<String, String> list) {
    return Container(
      color: Colors.white,
      alignment: Alignment.center,
      height: ScreenUtil().setHeight(80),
      padding: EdgeInsets.only(left: 30, right: 30),
      child: Row(
        children: <Widget>[
          Expanded(
            child: Text(
              title,
              textAlign: TextAlign.right,
            ),
            flex: 2,
          ),
          SizedBox(
            width: 5,
          ),
          Expanded(
            child: getDownButton2(list),
            flex: 6,
          )
        ],
      ),
    );
  }

  Widget getDownButton2(Map<String, String> list) {
    var list1 = List<DropdownMenuItem>();
    list.forEach((String key, String value) {
      list1.add(DropdownMenuItem(
          child: Text(value,
              style:
                  new TextStyle(fontSize: 12, color: const Color(0xff888888))),
          value: key));
    });
    return DropdownButtonHideUnderline(
        child: DropdownButton(
            items: list1,
            value: xmbValue,
            onChanged: (value) {
              setState(() {
                this.xmbValue = value;
              });
            }));
  }

  Widget getQuery(JsonQueryModel model) {
    return Container(
      // color: Colors.black12,
      alignment: Alignment.center,
      margin: EdgeInsets.only(top: 10),
      height: ScreenUtil().setHeight(80),
      padding: EdgeInsets.only(left: 30, right: 30),
      child: Row(
        children: <Widget>[
          Expanded(
            child: RaisedButton(
//          startDate: 2020-06-01
//          nextDate: 2020-06-24
//      networkBranch: 1
//      projectDepartment: 4
//
              onPressed: () {
                queryMap = Map();
                queryMap["nextDate"] = eDat;
                queryMap["startDate"] = sDate;
                queryMap["networkBranch"] = wgfgsValue;
                queryMap["projectDepartment"] = xmbValue;
                model.map = queryMap;
                model.query = false;
                model.getHttpData(data: queryMap);
              },
              child: Text("查询"),
              textColor: Colors.white,
              color: Theme.of(context).primaryColor,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(8),
                // side: BorderSide(color: Colors.red)
              ),
            ),
            flex: 1,
          ),
//          Text("   "),
//          Expanded(
//            child: RaisedButton(
//              onPressed: () {
//                Navigator.of(context).push(MaterialPageRoute(
//                    builder: (context) => AmapPage(queryMap)));
//              },
//              child: Text("查看地图"),
//              textColor: Colors.white,
//              color: Theme.of(context).primaryColor,
//              shape: RoundedRectangleBorder(
//                borderRadius: BorderRadius.circular(8),
//                // side: BorderSide(color: Colors.red)
//              ),
//            ),
//            flex: 1,
//          )
        ],
      ),
    );
  }

//  Widget getWrap() {
//    if (list == null) {
//      return Text(" ");
//    } else {
//      return Container(
////        padding: EdgeInsets.only(left: 30),
//        child: Wrap(
//          spacing: 1,
//          children: getListItem(),
//        ),
//      );
//    }
//  }

  Widget pintu() {
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[
          Card(
            color: Colors.white,
//            margin: EdgeInsets.only(left: 30, right: 30),
            child: Column(
              children: <Widget>[
                Container(
                  padding: EdgeInsets.only(top: 10, bottom: 10),
                  child: Text("抢险事件原因统计"),
                ),
                SizedBox(
                  height: 1,
                  width: ScreenUtil().setWidth(700),
                  child: Container(
                    color: Colors.black12,
                  ),
                ),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: getRowL(),
                      flex: 1,
                    ),
                    Expanded(
                      child: getPieC(),
                      flex: 1,
                    ),
                  ],
                )
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget getPieC() {
    return Container(
      alignment: Alignment.centerRight,
      height: ScreenUtil().setHeight(300),
      width: ScreenUtil().setWidth(250),
      child: PieChart(
        PieChartData(
            pieTouchData: PieTouchData(touchCallback: (pieTouchResponse) {
              setState(() {
                if (pieTouchResponse.touchInput is FlLongPressEnd ||
                    pieTouchResponse.touchInput is FlPanEnd) {
                  touchedIndex = -1;
                } else {
                  touchedIndex = pieTouchResponse.touchedSectionIndex;
                }
              });
            }),
            borderData: FlBorderData(
              show: false,
            ),
            sectionsSpace: 0,
            centerSpaceRadius: 0,
            sections: showList()),
      ),
    );
  }

  List<PieChartSectionData> showList() {
    if (this.datas == null) {
      return null;
    }

    var data = json.decode(this.datas);

    var datas = data["cause"];

    list = (datas as List).cast();
    if (null == list || list.isEmpty) {
      return null;
    }

    list.removeWhere((element) {
      return element["event_reason"] == "12";
    });
    list.removeWhere((element) {
      return element["event_reason"] == "11";
    });
    list.removeWhere((element) {
      return element["event_reason"] == "10";
    });
    list.removeWhere((element) {
      return element["event_reason"] == "9";
    });
    list.removeWhere((element) {
      return element["event_reason"] == "8";
    });
    list.removeWhere((element) {
      return element["event_reason"].toString().trim().length == 0;
    });

    return list.map((value) {
      return PieChartSectionData(
        color: colorMap[value["event_reason"].toString()],
        value: value["branch"].toDouble(),
        title: value["branch"].toString(),
        radius: 60,
        titleStyle: TextStyle(
            fontSize: 10,
            fontWeight: FontWeight.bold,
            color: const Color(0xffffffff)),
      );
    }).toList();
  }

  List<Container> getRowLs() {
    List<Container> listw;
    if (this.datas == null) {
      return null;
    }
    var data = json.decode(this.datas);
    var datas = data["cause"];
    list = (datas as List).cast();
    if (null == list || list.isEmpty) {
      return null;
    }
    list.removeWhere((element) {
      return element["event_reason"] == "12";
    });
    list.removeWhere((element) {
      return element["event_reason"] == "11";
    });
    list.removeWhere((element) {
      return element["event_reason"] == "10";
    });
    list.removeWhere((element) {
      return element["event_reason"] == "9";
    });
    list.removeWhere((element) {
      return element["event_reason"] == "8";
    });
    list.removeWhere((element) {
      return element["event_reason"].toString().trim().length == 0;
    });
//    list.removeAt(0);

    return list.map((value) {
      return Container(
        margin: EdgeInsets.only(left: 10),
        padding: EdgeInsets.only(bottom: 10),
        child: Indicator(
          color: colorMap[value["event_reason"].toString()],
          text: sgyyList[value["event_reason"].toString()],
          size: 10,
          isSquare: true,
        ),
      );
    }).toList();
  }

  Widget getRowL() {
    if (this.datas == null) {
      return Container();
    }
    return Container(
      margin: EdgeInsets.only(left: 15, top: 10),
      child: Column(
        children: getRowLs(),
      ),
    );
  }

  Widget pintu1() {
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[
          Card(
            color: Colors.white,
//            margin: EdgeInsets.only(left: 30, right: 30),
            child: Column(
              children: <Widget>[
                Container(
                  padding: EdgeInsets.only(top: 10, bottom: 10),
                  child: Text("施工工艺分析"),
                ),
                SizedBox(
                  height: 1,
                  width: ScreenUtil().setWidth(700),
                  child: Container(
                    color: Colors.black12,
                  ),
                ),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: getRowL1(),
                      flex: 1,
                    ),
                    Expanded(
                      child: getPieC1(),
                      flex: 1,
                    ),
                  ],
                )
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget getPieC1() {
    return Container(
      alignment: Alignment.centerRight,
      height: ScreenUtil().setHeight(300),
      width: ScreenUtil().setWidth(250),
      child: PieChart(
        PieChartData(
            pieTouchData: PieTouchData(touchCallback: (pieTouchResponse) {
              setState(() {
                if (pieTouchResponse.touchInput is FlLongPressEnd ||
                    pieTouchResponse.touchInput is FlPanEnd) {
                  touchedIndex = -1;
                } else {
                  touchedIndex = pieTouchResponse.touchedSectionIndex;
                }
              });
            }),
            borderData: FlBorderData(
              show: false,
            ),
            sectionsSpace: 0,
            centerSpaceRadius: 0,
            sections: showList1()),
      ),
    );
  }

  List<PieChartSectionData> showList1() {
    if (this.datas == null) {
      return null;
    }
    var data = json.decode(this.datas);

    var datas = data["technology"];

    technologylist = (datas as List).cast();
    if (null == technologylist || technologylist.isEmpty) {
      return null;
    }
//
//    technologylist.removeWhere((element){ return element["event_reason"]=="12";});
    technologylist.removeWhere((element) {
      return element["build_plan"] == "11";
    });
//    technologylist.removeWhere((element){ return element["event_reason"]=="10";});
//    technologylist.removeWhere((element){ return element["event_reason"]=="9";});
//    technologylist.removeWhere((element){ return element["event_reason"]=="8";});
//    technologylist.removeWhere((element){ return element["event_reason"]==null;});
//    technologylist.removeAt(0);

    return technologylist.map((value) {
      return PieChartSectionData(
        color: colorMap[value["build_plan"].toString()],
        value: value["branch"].toDouble(),
        title: value["branch"].toString(),
        radius: 60,
        titleStyle: TextStyle(
            fontSize: 10,
            fontWeight: FontWeight.bold,
            color: const Color(0xffffffff)),
      );
    }).toList();
  }

  List<Container> getRowLs1() {
    if (this.datas == null) {
      return null;
    }
    var data = json.decode(this.datas);
    var datas = data["technology"];
    technologylist = (datas as List).cast();
    if (null == technologylist || technologylist.isEmpty) {
      return null;
    }
//    list.removeWhere((element){ return element["event_reason"]=="12";});
    technologylist.removeWhere((element) {
      return element["build_plan"] == "11";
    });
//    list.removeWhere((element){ return element["event_reason"]=="10";});
//    list.removeWhere((element){ return element["event_reason"]=="9";});
//    list.removeWhere((element){ return element["event_reason"]=="8";});
//    list.removeWhere((element){ return element["event_reason"]==null;});
//    list.removeAt(0);

    return technologylist.map((value) {
      return Container(
        margin: EdgeInsets.only(left: 10),
        padding: EdgeInsets.only(bottom: 10),
        child: Indicator(
          color: colorMap[value["build_plan"].toString()],
          text: sgfeList[value["build_plan"].toString()],
          size: 10,
          isSquare: true,
        ),
      );
    }).toList();
  }

  Widget getRowL1() {
    if (this.datas == null) {
      return Container();
    }
    return Container(
      margin: EdgeInsets.only(left: 15, top: 10),
      child: Column(
        children: getRowLs1(),
      ),
    );
  }

  Widget pintu2() {
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[
          Card(
            color: Colors.white,
//            margin: EdgeInsets.only(left: 30, right: 30),
            child: Column(
              children: <Widget>[
                Container(
                  padding: EdgeInsets.only(top: 10, bottom: 10),
                  child: Text("抢险工程"),
                ),
                SizedBox(
                  height: 1,
                  width: ScreenUtil().setWidth(700),
                  child: Container(
                    color: Colors.black12,
                  ),
                ),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: getRowL2(),
                      flex: 1,
                    ),
                    Expanded(
                      child: getPieC2(),
                      flex: 1,
                    ),
                  ],
                )
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget getPieC2() {
    return Container(
      alignment: Alignment.centerRight,
      height: ScreenUtil().setHeight(300),
      width: ScreenUtil().setWidth(250),
      child: PieChart(
        PieChartData(
            pieTouchData: PieTouchData(touchCallback: (pieTouchResponse) {
              setState(() {
                if (pieTouchResponse.touchInput is FlLongPressEnd ||
                    pieTouchResponse.touchInput is FlPanEnd) {
                  touchedIndex = -1;
                } else {
                  touchedIndex = pieTouchResponse.touchedSectionIndex;
                }
              });
            }),
            borderData: FlBorderData(
              show: false,
            ),
            sectionsSpace: 0,
            centerSpaceRadius: 0,
            sections: showList2()),
      ),
    );
  }

  List<PieChartSectionData> showList2() {
    if (this.datas == null) {
      return null;
    }
    var data = json.decode(this.datas);
    var datas = data["analysis"];
    analysislist = (datas as List).cast();
    if (null == analysislist || analysislist.isEmpty) {
      return null;
    }

    analysislist.removeWhere((element) {
      return element["organization"] == "5";
    });
    return analysislist.map((value) {
      return PieChartSectionData(
        color: colorMap[value["organization"].toString()],
        value: value["branch"].toDouble(),
        title: value["branch"].toString(),
        radius: 60,
        titleStyle: TextStyle(
            fontSize: 10,
            fontWeight: FontWeight.bold,
            color: const Color(0xffffffff)),
      );
    }).toList();
  }

  List<Container> getRowLs2() {
    if (this.datas == null) {
      return null;
    }
    var data = json.decode(this.datas);
    var datas = data["analysis"];
    analysislist = (datas as List).cast();
    if (null == analysislist || analysislist.isEmpty) {
      return null;
    }
    analysislist.removeWhere((element) {
      return element["organization"] == "5";
    });
    return analysislist.map((value) {
      return Container(
        padding: EdgeInsets.only(bottom: 10, left: 10),
        child: Indicator(
          color: colorMap[value["organization"].toString()],
          text: technologyMap[value["organization"].toString()],
          size: 10,
          isSquare: true,
        ),
      );
    }).toList();
  }

  Widget getRowL2() {
    if (this.datas == null) {
      return Container();
    }
    return Container(
//      padding: EdgeInsets.only(top: 15),
      margin: EdgeInsets.only(left: 15, top: 10),
      child: Column(
        children: getRowLs2(),
      ),
    );
  }

  Widget pintu3() {
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[
          Card(
            color: Colors.white,
//            margin: EdgeInsets.only(left: 30, right: 30),
            child: Column(
              children: <Widget>[
                Container(
                  padding: EdgeInsets.only(top: 10, bottom: 10),
                  child: Text("处理时间分析"),
                ),
                SizedBox(
                  height: 1,
                  width: ScreenUtil().setWidth(700),
                  child: Container(
                    color: Colors.black12,
                  ),
                ),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: getRowL3(),
                      flex: 1,
                    ),
                    Expanded(
                      child: getPieC3(),
                      flex: 1,
                    ),
                  ],
                )
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget getPieC3() {
    return Container(
      alignment: Alignment.centerRight,
      height: ScreenUtil().setHeight(300),
      width: ScreenUtil().setWidth(250),
      child: PieChart(
        PieChartData(
            pieTouchData: PieTouchData(touchCallback: (pieTouchResponse) {
              setState(() {
                if (pieTouchResponse.touchInput is FlLongPressEnd ||
                    pieTouchResponse.touchInput is FlPanEnd) {
                  touchedIndex = -1;
                } else {
                  touchedIndex = pieTouchResponse.touchedSectionIndex;
                }
              });
            }),
            borderData: FlBorderData(
              show: false,
            ),
            sectionsSpace: 0,
            centerSpaceRadius: 0,
            sections: showList3()),
      ),
    );
  }

  List<PieChartSectionData> showList3() {
    if (this.datas == null) {
      return null;
    }
    var data = json.decode(this.datas);
    var datas = data["handletime"];

    handletimelist = (datas as List).cast();
    if (null == handletimelist || handletimelist.isEmpty) {
      return null;
    }
    int i = 1;
    return handletimelist.map((value) {
      return PieChartSectionData(
        color: colorMap[(i++).toString()],
        value: value["branch"].toDouble(),
        title: value["branch"].toString(),
        radius: 60,
        titleStyle: TextStyle(
            fontSize: 10,
            fontWeight: FontWeight.bold,
            color: const Color(0xffffffff)),
      );
    }).toList();
  }

  List<Container> getRowLs3() {
    if (this.datas == null) {
      return null;
    }
    var data = json.decode(this.datas);
    var datas = data["handletime"];
    handletimelist = (datas as List).cast();
    if (null == handletimelist || handletimelist.isEmpty) {
      return null;
    }
    int i = 1;
    return handletimelist.map((value) {
      return Container(
        padding: EdgeInsets.only(bottom: 10, left: 10),
        child: Indicator(
          color: colorMap[(i++).toString()],
          text: value["handle_time"].toString(),
          size: 10,
          isSquare: true,
        ),
      );
    }).toList();
  }

  Widget getRowL3() {
    if (this.datas == null) {
      return Container();
    }
    return Container(
//      padding: EdgeInsets.only(top: 15),
      margin: EdgeInsets.only(left: 15, top: 10),
      child: Column(
        children: getRowLs3(),
      ),
    );
  }
}
